import { Message } from 'element-ui';
import { request } from '../../common/request.js';
import { deepClone, formatMoney } from '../../common/utils.js';
export default {
    data() {
        return {
            sizeModel: 'small',
            labelWidth: '100px',
            activeNames: ['1'],
            param: {
                size: 10,
                page: 1,
                key: '',
            },
            total: 0,
            pageNum: [10,20,50],
            list: [],
            multipleSelection: [],
            isShowDialog: false,
            dialogParam: {
                enterPriseName: '',
                enterPriseId: '',
                availBalance: '',
                bankAccount: '',
                freezeBalance: ''
            },
            loading: false
        }
    },

    components: {},

    computed: {

    },
    filters: {
        filterMoney(val) {
            return formatMoney(val);
        }
    },
    methods: {
        // 查询列表
        search() {
            this.loading = true;
            request({
                url: 'getEnterpriseList',
                params: this.param,
                method: 'get'
            }).then(res => {
                if (res) {
                    this.list = res.list;
                    this.total = res.pagebar.total;
                    this.loading = false;
                }
            });
        },
        // 重置查询
        searchReset() {
            this.param.page = 1;
            this.param = {
                size: 10,
                page: 1,
                serialNum: '',
                key: '',
                status: '',
            };
            this.search();
        },
        // 改变表格列表个数
        handleSizeChange(val) {
            this.param.size = val;
            this.search();
        },
        //
        pageSearch(val) {
            this.param.page = val;
            this.search()
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        getDetails(info) {
            this.dialogParam = {
                enterPriseName: info.enterPriseName,
                enterPriseId: info.userId,
                availBalance: info.availBalance,
                bankAccount: '',
                freezeBalance: ''
            }
            this.isShowDialog = true;
        },
        getInvestDetail() {
            this.$router.push({
                path: '/investMoney',
                query: {
                    isShowRecords: 1
                }
            })
        },
        toTaskDetail() {
            this.$router.push({
                path: '/taskList',
                query: {
                    isShowTaskDetail: 1
                }
            })
        },
        // 给表头添加背景颜色
        getRowClass ({row, column, rowIndex, columnIndex}) {
            if (rowIndex === 0) {
                return 'height: 50px'
            } else {
                return ''
            }
        },
    },
    mounted(){
        this.search()
    }
}
